package test.nine;
import static util.Util.*;

interface Service{
	void method1();
	void method2();
}
interface ServiceFactory{
	Service getService();
}
class Implmentation1 implements Service{
	Implmentation1(){}
	public void method1(){print("Implmentation1 method1");}
	public void method2(){print("Implmentation1 method2");}
}
class Implmentation1Factory implements ServiceFactory{
	public Service getService() {
		return new Implmentation1();
	}
}

class Implmentation2 implements Service{
	Implmentation2(){}
	public void method1(){print("Implmentation2 method1");}
	public void method2(){print("Implmentation2 method2");}
}
class Implmentation2Factory implements ServiceFactory{
	public Service getService() {
		return new Implmentation2();
	}
}

public class Factories {
	public static void serviceConsumer(ServiceFactory fact){
		Service s=fact.getService();
		s.method1();
		s.method2();
	}
	
	public static void main(String[] args) {
		serviceConsumer(new Implmentation1Factory());
		serviceConsumer(new Implmentation2Factory());
	}
}
